//
//  PayViewController.m
//  YUXiu
//
//  Created by wang on 16/6/29.
//  Copyright © 2016年 Wang. All rights reserved.
//

#import "PayViewController.h"
#import "CourceHomeCell.h"

@interface PayViewController (){
    UIView *coverView;
}

@end


@implementation PayViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"确认支付";
    self.tableView.tableFooterView = [self getFootView];
}


#pragma mark - TabelView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *iden = @"cell";
    CourceHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:iden];
    if (!cell) {
        cell = [[CourceHomeCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:iden Model:nil];
    }
    [cell.memberShare setHidden:YES];
    cell.priceLabel.text = @"50钻";
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 40;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *foot = [[UIView alloc]initWithFrame:krect(0, 0, kScreenWidth, 40)];
    foot.backgroundColor = kNaviBarCOLOR;
    UILabel *lab = [[UILabel alloc]initWithFrame:krect(13, 10, kScreenWidth-30, 20)];
    lab.textColor = kLightGrayCOLOR;
    lab.text = @"帐户余额: 500钻";
    [foot addSubview:lab];
    
    return foot;
}
-(UIView *)getFootView{
    UIView *bottomView = [[UIView alloc]initWithFrame:krect(0, 0, kScreenWidth, 80)];
    UIButton *bottom = [[UIButton alloc]initWithFrame:krect(15, 20, kScreenWidth-30, 40)];
    [bottom setBackgroundColor:kOrangeCOLOR];
    [bottom setTitle:@"立即支付" forState:UIControlStateNormal];
    [bottom setTitleColor:kWhiteCOLOR forState:UIControlStateNormal];
    bottom.layer.cornerRadius = 5;
    [bottom addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:bottom];
    
    return bottomView;
}
#pragma mark - Touch Event
-(void)click{
    if (!coverView) {
        coverView = [[UIView alloc]initWithFrame:krect(0, 0, kScreenWidth, kScreenHeight)];
        coverView.backgroundColor = kBlackCOLOR;
        coverView.alpha = 0.2;
        [kKeyWindow addSubview:coverView];
    }else{
        [coverView setHidden:NO];
    }
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"确定支付50钻?" delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"确定", nil];
    [alert show];

    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    switch (buttonIndex) {
        case 0:
            NSLog(@"cancel");
            break;
            case 1:
            NSLog(@"sure");
            [self showHUDWithText:@"支付成功" AfterDelay:1];
            break;
        default:
            break;
    }
    [coverView setHidden:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
